Skip to content

Align all paper example figures with MATLAB layouts and styles#76

Merged
iahncajigas merged 12 commits intomainfrom
fix/example05-figures-matlab-parity
Mar 24, 2026
Merged

Align all paper example figures with MATLAB layouts and styles#76
iahncajigas merged 12 commits intomainfrom
fix/example05-figures-matlab-parity

Conversation

@iahncajigas
Copy link
Copy Markdown
Contributor

Summary

  • Cross-referenced all 5 MATLAB paper example scripts against their Python counterparts and aligned subplot grids, axis labels, titles, fonts, line widths, markers, ticks, and legends
  • Regenerated all 25 figures in both examples/paper/figures/ and docs/figures/
  • No MATLAB bugs found during the audit

Per-example changes

  • Example 01: Replaced plotResults() with explicit 2×2 grid matching MATLAB (raster + InvGausTrans + KSPlot + lambda); added red epoch lines and dual-lambda overlay in Figure 3
  • Example 02: Matched MATLAB 16pt titles, axis tick formatting, suppressed top-panel x-labels, added "Displacement Velocity" title, hid coefficient legend
  • Example 03: Matched MATLAB CIF title wording, mesh wireframe appearance (edgecolor/alpha), figsize (14,9) for surface plots
  • Example 04: Added axis('square'), XTick/YTick [-1:0.5:1], Cell# titles, legend on subplot 4, removed subplot borders for place fields, matched sgtitle format
  • Example 05: Matched figsize (14,9), linewidth=4 for decoded traces, 18pt title, show all cells in hybrid raster, suppressed raster x-labels

Test plan

  • All 5 examples run end-to-end with --export-figures
  • 25 figures regenerated and match MATLAB visual layout
  • Paper example asset tests pass (pytest tests/ -k paper)

🤖 Generated with Claude Code

@iahncajigas iahncajigas reopened this Mar 23, 2026
Iahn Cajigas and others added 7 commits March 23, 2026 20:55
Part B (Figures 3-4):
- Replace sinusoidal trajectory with minimum-jerk reaching dynamics
  (cosine acceleration toward target), matching MATLAB exactly
- Fix encoding parameters: delta=0.001, mu=log(10*delta)+randn,
  beta=10*(rand-0.5) uniform velocity tuning
- Figure 3: 4x2 layout with reach path, pos/vel traces, raster, CIF
- Figure 4: overlaid decoded trajectories (20 runs, blue=goal, green=free)

Part C (Figures 5-6):
- Load 6-state fixture (paperHybridFilterExample.mat) with 2D hold
  and 6D reach modes, matching MATLAB's different-dimension-per-mode
  hybrid filter architecture
- Figure 5: 4x2 layout with reach path, pos/vel traces, raster,
  discrete state (N/M)
- Figure 6: 4x3 layout with state estimation, P(M|data), 2D decoded
  path, per-component traces — averaged over 20 simulations with both
  goal-directed and free hybrid decoding

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The likelihood computation in PPHybridFilterLinear and PPHybridFilter
used sqrt(det(W_u)) / max(sqrt(det(W_p)), 1e-15) which catastrophically
fails for ≥6-D states: with eigenvalues ~1e-10, det ≈ 1e-46 and
sqrt(det) ≈ 1e-23 — far below the 1e-15 floor — collapsing the reach
model likelihood to zero permanently.

Replace with np.linalg.slogdet() log-space computation that matches
MATLAB's raw det ratio while avoiding overflow/underflow.

Verified: 100% discrete-state agreement with MATLAB (fixed) on the
paperHybridFilterExample fixture for both free and goal-directed cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Regenerated all 24 figures across 5 paper examples with latest code
- Re-executed all 29 help notebooks (helpfiles) with fresh outputs
- Added example figure exports to examples/paper/figures/ (new)
- Updated docs/figures/ gallery with cleaned manifest-matching figures
- Fixed test_network_tutorial_builder to strip execution metadata

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Documentation links now point to actual Sphinx-generated paths
  (help/index.html, help/paper_overview.html, etc.) instead of
  non-existent flat filenames (NeuralSpikeAnalysis_top.html, etc.)
- Fix parity report link: parity/parity_report.md -> parity/report.md
- Add parity dashboard and API reference links
- Remove stale DocumentationSetup.md source page reference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…, and styles

Cross-referenced all MATLAB example scripts against Python to match subplot
grids, axis labels, title text, font properties (Arial, bold, 12-16pt),
line widths, marker styles, tick formatting, and legend content.

Key changes per example:
- Ex01: Replace plotResults() with explicit 2x2 grid matching MATLAB (raster,
  InvGausTrans, KSPlot, lambda); add red epoch lines and dual-lambda plot
- Ex02: Match MATLAB 16pt titles, axis tick formatting, suppress top-panel
  x-labels, use "Displacement Velocity" title, hide coefficient legend
- Ex03: Match MATLAB CIF title wording, mesh wireframe appearance with
  edgecolor/alpha, figsize (14,9) for surface plots
- Ex04: Add axis('square'), XTick/YTick [-1:0.5:1], Cell# titles, legend on
  subplot 4, remove subplot borders for place fields, sgtitle format
- Ex05: Match figsize (14,9), linewidth=4 for decoded traces, 18pt title,
  show all cells in hybrid raster, suppress raster x-labels

Regenerated all 25 figures in both examples/paper/figures/ and docs/figures/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The test_readme_links_to_help_navigation_pages test expects all five
MATLAB-style navigation pages to be linked in the README. The
DocumentationSetup.md page existed in docs/ but was not listed in the
Source pages section.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Figure fixes (all 5 examples):
- Ex01 Fig3: Epoch lines bounded to [0,1] instead of full y-axis (axvline → plot)
- Ex02 Fig1: Add axis linewidth=1 on subplots 2-3 (matching MATLAB set(gca,'LineWidth',1))
- Ex03 Fig3: CIF heatmap uses jet colormap (matching MATLAB imagesc default)
- Ex03 Fig5: plot_wireframe instead of plot_surface (matching MATLAB mesh())
- Ex03 Fig2: PSTH/GLM z-order swapped to match MATLAB (GLM drawn before PSTH markers)
- Ex03 Fig6: Significance markers markersize 3→6; axis label positions moved to top/right
- Ex04 Fig1: Aspect ratio 12×10→14×9 (matching MATLAB 1400×900)
- Ex04 Fig2: Figure height 5→9 inches
- Ex04 Figs3-6: Fixed heatmap heights to 14×9 instead of scaling with row count
- Ex04 Fig7: plot_wireframe instead of plot_surface with Line2D legend entries
- Ex05: Raster markersize 2→4; added missing "Stimulus" ylabel on Fig2

README restructured to match MATLAB README flow:
- Added subtitle "Neural Spike Train Analysis Toolbox for Python"
- Moved CI badge to after title
- Removed broken pages.yml badge (no workflow exists)
- Consolidated install/data/setup into single "How to install nSTAT" section
- Merged License, Cite, Data into single section
- Added PyPI install one-liner before lab websites

Docs:
- Added CITATION.cff mirroring MATLAB repo
- Regenerated all 25 paper-example figures

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@iahncajigas iahncajigas force-pushed the fix/example05-figures-matlab-parity branch from 85283d5 to 93bf900 Compare March 24, 2026 00:55
Iahn Cajigas and others added 5 commits March 23, 2026 21:12
- example03: Add missing K_mesh/T_mesh meshgrid for Figure 5 wireframe
  surfaces (NameError at runtime)
- example05: Add missing _simulate_binomial_spikes() helper that computes
  CIF from state/coefficients then draws spikes (NameError in Parts B/C)
- example05: Fix x_true → stimSignal reference in Figure 2 plotting
- example05: Remove dead "setup" key from _load_hybrid_fixture() return
- Regenerate all affected figures for examples 03 and 05

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- AnalysisExamples2.ipynb: getCoeffs() returns (coeffs, labels, SE) tuple,
  need [0] to extract coefficient array for subtraction
- StimulusDecode2D.ipynb: parity note said 'exact' but parity_notes.yml
  says 'high_fidelity'; align notebook to YAML

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Trim algorithm-specific details from overview (SSGLM, UKF, PPAF, PPHF)
  to match MATLAB's general-purpose intro paragraphs
- Move Plot Style into Paper Examples section (matching MATLAB placement)
- Add Quickstart block (matching MATLAB's run_all_checks one-liner)
- Simplify Documentation to single GitHub Pages URL (matching MATLAB)
- Remove standalone Supplementary Examples and Developer Notes sections
- Trim Toolbox Map to 5 bullets matching MATLAB's structure
- Consolidate citation/license into flowing prose (matching MATLAB)
- Update test_docs_surface.py: replace per-page README link test with
  GitHub Pages site link test (mirrors MATLAB README structure)
- Fix StimulusDecode2D.ipynb parity note remaining_differences to match
  parity_notes.yml

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- paper_gallery.py: Output "## Paper Examples (Self-Contained)" heading
  to match MATLAB's "Paper Examples (Self-Contained)" section structure
- paper_gallery.py: Remove Supplementary Examples from generated output
  (MATLAB README has no equivalent section)
- paper_gallery.py: Update README delimiters for new section headings
- test_docs_surface.py: Replace per-page README link tests with GitHub
  Pages URL and PaperOverview link tests (matching MATLAB's single-URL
  documentation reference)
- StimulusDecode2D.ipynb: Align parity note with parity_notes.yml

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…le04 figures

- test_paper_gallery_docs.py: Update delimiter from "## Examples" to
  "## Paper Examples (Self-Contained)" / "Plot style policy:"
- test_readme_examples_catalog.py: Remove Supplementary Examples test
  (section removed from README for MATLAB parity); update block extractor
- test_readme_nstatpaperexamples.py: Update regex for new section heading
- Regenerate example04 figures at full DPI=250 resolution (3500x2250)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@iahncajigas iahncajigas merged commit 71a104e into main Mar 24, 2026
15 checks passed
@iahncajigas iahncajigas deleted the fix/example05-figures-matlab-parity branch March 24, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant